package tms.util.localization;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import java.util.Locale;

public class Constant {
    private String id;
    private String english;
    private String russian;


    @XmlAttribute(name = "id")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @XmlElement(name = "en")
    public String getEn() {
        return english;
    }

    public void setEn(String english) {
        this.english = english;
    }

    @XmlElement(name = "ru")
    public String getRu() {
        return russian;
    }

    public void setRu(String russian) {
        this.russian = russian;
    }

    public String getLocalized(Locale locale) {
        String retVal = "";

        String language = locale.getLanguage();
        if (language.equals("en")) {
            retVal = getEn();
        } else if (language.equals("ru")) {
            retVal = getRu();
        }

        return retVal;
    }



    public static enum SupportedLocale {
        ru("ru"),
        en("en");

        private Locale locale;
    
        SupportedLocale(String language) {
            locale = new Locale(language);
        }

        public Locale locale() {
            return locale;
        }

        public static Locale defaultLocale() {
            return en.locale();
        }
    }
}
